package Boss直聘.奥枫.数组合并;

public class Main {
    public static void main(String[] args){
        int a [] = {2,4,6,8};
        int b [] = {1,3,5,7,9,11,13};
//        int c[] = functuin1(a,b);
//        for (int d = 0;d<c.length;d++){
//            System.out.println(c[d]);
//        }
    }

    private static int[] functuin1(int[] a, int[] b) {
        int c [] = new int[a.length+b.length];//定义数组
        int za=0,zb=0,zc=0;//定义指针
        for (zc=0;zc<a.length+b.length;zc++){
            if((za==a.length)&&(zb==b.length)) break;
            if (za!=a.length||a[za]<b[zb]){
                c[zc]=a[za];
                za++;
            }else if(zb!=b.length||a[za]>b[zb]){
                c[zc]=b[zb];
                zb++;
            }else{
                c[zc]=a[za];
                za++;
                zb++;
            }
        }

        return c;
    }


}
